﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace AssignmentsManage.TemplateSelectors
{
    public class ListViewItemStyleAlternateSelector : StyleSelector
    {
        public Style ListViewItemRow1 { get; set; }
        public Style ListViewItemRow2 { get; set; }

        public override Style SelectStyle(object item, DependencyObject container)
        {
            ListView listView = ItemsControl.ItemsControlFromItemContainer(container) as ListView;

            Style st;

            int index = listView.ItemContainerGenerator.IndexFromContainer(container);

            if (index % 2 == 0)
            {

                st = ListViewItemRow2;

            }

            else
            {

                st = ListViewItemRow1;

            }

            return st;

        }
    }
}
